package com.xhu.controller;

import com.xhu.pojo.UserGameRel;
import com.xhu.service.GameService;
import com.xhu.utils.ResponseMessage;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/game")
public class GameController {
    @Autowired
    private GameService gameService;

    @GetMapping("/gameListByUserId/{userId}")
    public ResponseMessage gameListByUserId(@PathVariable String  userId){
        return gameService.gameListByUserId(userId);
    }

    @DeleteMapping ("/deleteUserGameRel")
    public  ResponseMessage deleteUserGameRel(@RequestParam(value = "userId") Integer userId,@RequestParam(value = "gameId")Integer gameId){
        return gameService.deleteUserGameRel(userId,gameId);
    }

    @GetMapping("/allGameList")
    public ResponseMessage allGameList(){
        return gameService.allGameList();
    }

    @PutMapping("/addGameByUser")
    public ResponseMessage addGameByUser(@RequestBody UserGameRel userGameRel){
        return gameService.addGameByUser(userGameRel);
    }
}
